package com.solution.admin.sysconfig.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.solution.admin.sysconfig.dao.WechatArticleDao;
import com.solution.admin.sysconfig.entity.WechatArticleEntity;
import com.solution.common.dao.impl.BaseDaoImpl;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;

/**
 * 微信文章管理DAO实现
 * @author solin
 * @date 2018-02-09 09:41:15
 */
@Repository
public class WechatArticleDaoImpl extends BaseDaoImpl<WechatArticleEntity> implements WechatArticleDao {
	
	@Autowired
	SqlSessionTemplate sqlSessionTemplate;

	/**
	 * 保存微信文章管理信息
	 * @param wechatArticleEntity
	 * @return
	 * @author solin
	 * @date 2018-02-09 09:41:15
	 */
	@Override
	public long saveWechatArticle(WechatArticleEntity wechatArticleEntity) {
		return super.insert(wechatArticleEntity);
	}

	/**
	 * 分页查询微信文章管理信息
	 * @param pageParam 分页对象
	 * @param wechatArticle 分页参数
	 * @return PageBean 分页参数及数据
	 * @author solin
	 * @date 2018-02-09 09:41:15
	 */
	public PageBean listWechatArticlePage(PageParam pageParam, Map<String, Object> param) {
		return super.listPage(pageParam, param);
	}

	/**
	 * 更新微信文章管理
	 * @param wechatArticleEntity
	 * @return
	 * @author solin
	 * @date 2018-02-09 09:41:15
	 */
	@Override
	public int updateWechatArticle(WechatArticleEntity wechatArticleEntity) {
		return super.update(wechatArticleEntity);
	}

	/**
	 * 删除微信文章管理
	 * @param wechatArticleId
	 * @return
	 * @author solin
	 * @date 2018-02-09 09:41:15
	 */
	public int deleteWechatArticleById( Long id) {
		return super.deleteById(id);
	}
	
	/**
	 * 根据条件查询微信文章管理
	 * @param param
	 * @return
	 * @author solin
	 * @date 2018-02-09 09:41:15
	 */
	@Override
	public List<WechatArticleEntity> listWechatArticle( Map<String, Object> param) {
		return super.listBy(param);
	}
	
	/**
	 * 通过消息ID删除文章
	 * @param param
	 * @return
	 * @author: solin
	 * @date: 2018年2月9日 下午2:05:49
	 */
	@Override
	public int deleteByMsgId(long msgId) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("msgId", msgId);
		return sqlSessionTemplate.delete("deleteByMsgId", param);
	}
}
